from utilities import fasta, ssearch, constants
def find_utr_in_ests(filename):
    ifile = fasta.Fasta_file(filename, 'r')
    ofile = fasta.Fasta_file(filename.rpartition('.')[0]+'_utr.out.fasta', options='w')
    while ifile.next():
        index = ssearch.search_for_uniques(ifile.seq.upper(), constants.STOP_CODONS_DNA)
        if index > 0:
            ofile.write(ifile.seqname.rstrip('\n')+'_utr', ifile.seq[index+3:len(ifile.seq)].rstrip('\n'))

import os
os.chdir('/home/tsuname/Desktop/biomedicas/est')
find_utr_in_ests('adulto.split.seq')
find_utr_in_ests('larva.split.seq')
find_utr_in_ests('japan_full_length.seq')